package org.jeecg.modules.demo.crm.service.impl;

import org.checkerframework.checker.units.qual.A;
import org.jeecg.modules.demo.crm.dto.SubmitReviewDTO;
import org.jeecg.modules.demo.crm.entity.CContractorInfo;
import org.jeecg.modules.demo.crm.entity.CSubProjectTask;
import org.jeecg.modules.demo.crm.mapper.CSubProjectTaskMapper;
import org.jeecg.modules.demo.crm.service.ICSubProjectTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import static org.jeecg.modules.demo.crm.util.DateUtils.dateToString;

/**
 * @Description: 子项任务表
 * @Author: jeecg-boot
 * @Date:   2025-05-31
 * @Version: V1.0
 */
@Service
public class CSubProjectTaskServiceImpl extends ServiceImpl<CSubProjectTaskMapper, CSubProjectTask> implements ICSubProjectTaskService {


    @Autowired
    private CSubProjectTaskMapper cSubProjectTaskMapper;
    @Override
    public List<SubmitReviewDTO> cSubProjectTask(String subProjectId) {
        List<SubmitReviewDTO> dataList = new ArrayList<>();
        List<CSubProjectTask>  data = cSubProjectTaskMapper.findBySubProjectId(subProjectId);
        for (CSubProjectTask task : data) {
            SubmitReviewDTO result = new SubmitReviewDTO();
            result.setId(task.getId());
            result.setTaskName(task.getTaskName());
            result.setStatus(task.getStatus());
            result.setQuantity(task.getQuantity());
            result.setUnit(task.getUnit());
            result.setMainPrice(task.getMainPrice());
            result.setAuxiliaryPrice(task.getAuxiliaryPrice());
            result.setLaborPrice(task.getLaborPrice());
            result.setTotalContractor(task.getTotalContractor());
            result.setRemark(task.getRemark());
            result.setModel(task.getModel());
            result.setBrand(task.getBrand());
            result.setContract("");
            result.setIsNew(false);
            //result.setKey();
            dataList.add(result);
        }
        return dataList;
    }

    @Override
    public List<CSubProjectTask> contractorInfoList(String subProjectId) {
        return cSubProjectTaskMapper.contractorInfoList(subProjectId);
    }




}
